package org.qiandaosystem.qiandaosystemsource.mapper;

import org.apache.ibatis.annotations.*;
import org.qiandaosystem.qiandaosystemsource.entity.Teacher;

@Mapper
public interface TeacherMapper {
    
    @Select("SELECT * FROM teachers WHERE user_id = #{userId}")
    Teacher findByUserId(Integer userId);
    
    @Select("SELECT * FROM teachers WHERE `Key` = #{key}")
    Teacher findByKey(String key);
    
    @Insert("INSERT INTO teachers(user_id, real_name, `Key`) VALUES(#{userId}, #{realName}, #{key})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Teacher teacher);
    
    @Update("UPDATE teachers SET real_name = #{realName}, `Key` = #{key} WHERE user_id = #{userId}")
    int update(Teacher teacher);
    
    @Delete("DELETE FROM teachers WHERE user_id = #{userId}")
    int deleteByUserId(Integer userId);
} 